<!-- @format -->

<template>
	<div class="ma-content-block lg:flex justify-between p-4">
		<!-- CRUD 组件 预报单 -->
		<ma-crud
			:options="options"
			:columns="columnsYBDJZX"
			ref="crudRefYBDJZX"
			tableRef='tableRefxxx'
			v-if="
				(inforow?.pick_type == 1 || inforow?.pick_type == 2) &&
				inforow?.transport_type == 1
			"
		>
			<template #warehouse_user_detail_id="{ record }">
				<a-tag style="margin-top: 5px" color="blue" v-if="record.wareuserdetail.warehouse_log_chu != null"
					>{{ record.wareuserdetail.warehouse_log_chu?.horizontal_position }}-{{
						record.wareuserdetail.warehouse_log_chu?.release_position
					}}-{{ record.wareuserdetail.warehouse_log_chu?.reaches_position }}</a-tag
				>
				<div v-else></div>
			</template>	
		</ma-crud>
		<!-- CRUD 组件 仓储 -->
		<ma-crud
			:options="options"
			:columns="columnsCKJZX"
			ref="crudRefCKJZX"
			v-if="
				(inforow?.pick_type == 3 || inforow?.pick_type == 4) &&
				inforow?.transport_type == 1
			"
		>
			<template #warehouse_user_detail_id="{ record }">
				<a-tag style="margin-top: 5px" color="blue" v-if="record.wareuserdetail.warehouse_log_chu != null"
					>{{ record.wareuserdetail.warehouse_log_chu?.horizontal_position }}-{{
						record.wareuserdetail.warehouse_log_chu?.release_position
					}}-{{ record.wareuserdetail.warehouse_log_chu?.reaches_position }}</a-tag
				>
				<div v-else></div>
			</template>
		</ma-crud>
	</div>
</template>
<script setup>
	import { ref, reactive } from "vue";
	import predictionDeriverOrderDetail from "@/api/prediction/predictionDeriverOrderDetail";
	import { Message } from "@arco-design/web-vue";
	import tool from "@/utils/tool";
	import * as common from "@/utils/common";
	const crudRefYBDJZX = ref();
	const crudRefCKJZX = ref();
	const order_id = ref();
	const inforow = ref();
	const rowData = ref({is_taoxiang:0})
	const columnsYBDJZX = ref([
						{
							title: "运单号",
							dataIndex: "prediction.yundanhao",
							formType: "input",
							align: "center",
							// search: true,
						},
						{
							title: "车号",
							dataIndex: "prediction.car_no",
							formType: "input",
							align: "center",
							// search: true,
						},
						{
							title: "品名",
							dataIndex: "prediction.goods_name",
							formType: "input",
							align: "center",
							// search: true,
						},
						
						{
							title: "箱号",
							dataIndex: "prediction.box",
							align: "center",
							formType: "input",
							// search: true,
						},
						{
							title: "集装箱型",
							dataIndex: "prediction.box_type",
							align: "center",
							formType: "input",
							// search: true,
						},
						{
							title: "箱属",
							dataIndex: "prediction.box_belong",
							align: "center",
							formType: "input",
							// search: true,
						},
						{
							title: "件数",
							dataIndex: "pick_number",
							align: "center",
							formType: "input",
							hide:rowData.value.is_taoxiang == 1?false:true
							// search: true,
						},
						{
							title: "重量",
							dataIndex: "pick_weight",
							align: "center",
							formType: "input",
							hide:rowData.value.is_taoxiang == 1?false:true
							// search: true,
						},
						{
							title: "创建时间",
							dataIndex: "created_at",
							formType: "date",
							addDisplay: false,
							editDisplay: false,
							hide: true,
							showTime: true,
						},
						{
							title: "创建时间",
							dataIndex: "created_at",
							formType: "date",
							align: "center",
							addDisplay: false,
							editDisplay: false,
							hide: true,
							showTime: true,
						},
						{
							title: "更新时间",
							dataIndex: "updated_at",
							formType: "date",
							addDisplay: false,
							editDisplay: false,
							hide: true,
							showTime: true,
						},
						{
							title: "删除时间",
							dataIndex: "deleted_at",
							formType: "date",
							addDisplay: false,
							editDisplay: false,
							hide: true,
							showTime: true,
						},
	])
	const columnsCKJZX = ref([
						{
							title: "运单号",
							dataIndex: "prediction.yundanhao",
							formType: "input",
							align: "center",
							// search: true,
						},

					
						{
							title: "品名",
							dataIndex: "wareuserdetail.goods_name",
							align: "center",
							formType: "input",
							// search: true,
						},
						
						{
							title: "集装箱",
							dataIndex: "wareuserdetail.box",
							formType: "input",
							// search: true,
						},
						{
							title: "箱型箱类",
							dataIndex: "wareuserdetail.box_type",
							formType: "input",
							// search: true,
						},
						{
							title: "箱属",
							dataIndex: "wareuserdetail.box_belong",
							formType: "input",
							// search: true,
						},
						{
							title: "仓库",
							dataIndex: "wareuserdetail.warehouse_log_chu.warehouse.name",
							align: "center",
							formType: "input",
							search: false,
						},
						{
							title: "仓位（横-纵-层）",
							dataIndex: "warehouse_user_detail_id",
							align: "center",
							formType: "input",
							search: false,
						},
						{
							title: "件数",
							dataIndex: "pick_number",
							align: "center",
							formType: "input",
							hide:rowData.value.is_taoxiang == 1?false:true
							// search: true,
						},
						{
							title: "重量",
							dataIndex: "pick_weight",
							align: "center",
							formType: "input",
							hide:rowData.value.is_taoxiang == 1?false:true
							// search: true,
						},
	])
	const open = (row, inforows) => {
		rowData.value = row
		order_id.value = row.id;
		inforow.value = inforows;
		setTimeout(() => {
			if (row.pick_type == 1 || row.pick_type == 2) {
				if (row.transport_type == 1) {
					// 预报单  集装箱
					crudRefYBDJZX.value.requestData();
				}
			} else if (row.pick_type == 3 || row.pick_type == 4) {
				if (row.transport_type == 1) {
					// 仓库   集装箱提货
					crudRefCKJZX.value.requestData();
				}
			}


			console.log(columnsYBDJZX.value)
		}, 50);
		
	};

	const options = reactive({
		id: "flyos_prediction_deriver_order_detail",
		// rowSelection: {
		//   showCheckedAll: true
		// },
		pk: "id",
		autoRequest:false,
		bordered: { cell: true },
		operationColumn: false,
		expandSearch: false,
		operationWidth: 160,
		formOption: {
			viewType: "modal",
			width: 600,
		},
		api: predictionDeriverOrderDetail.getList,
		exports: {
			show: true,
		},
		beforeRequest: (params) => {
			params.order_id = order_id.value;
			params.order = "created_at";
			params.orderType = "desc";
		},
		afterRequest:(params)=>{
		}
	});
	defineExpose({ open });
</script>
<script>
	export default { name: "prediction:deriverOrderDetail" };
</script>
